package com.lagou.sqlsession;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;

public interface SqlSession {

    /**
     * 列表查询
     * @param <E>
     * @return
     */
    public  <E>List<E> selecList(String statementid,Object... params) throws SQLException, ClassNotFoundException, InvocationTargetException, IntrospectionException, InstantiationException, IllegalAccessException, NoSuchFieldException;

    /**
     * 查询单条记录
     * @param statementid
     * @param params
     * @return
     */
    public <T> T   selectOne(String statementid,Object... params) throws SQLException, ClassNotFoundException, IntrospectionException, InstantiationException, IllegalAccessException, NoSuchFieldException, InvocationTargetException;


    /**
     * 写入操作
     * @param statementid
     * @param params
     * @return
     */
    public int inser(String statementid,Object... params) throws ClassNotFoundException, SQLException, IllegalAccessException, NoSuchFieldException;


    /**
     * 写入操作
     * @param statementid
     * @param params
     * @return
     */
    public int update(String statementid,Object... params) throws ClassNotFoundException, SQLException, NoSuchFieldException, IllegalAccessException;


    /**
     * 删除
     * @param statementid
     * @param params
     * @return
     */
    public int delete(String statementid,Object... params) throws ClassNotFoundException, SQLException, IllegalAccessException, NoSuchFieldException;


    /**
     * 获取动态代理对象
     * @param type
     * @param <T>
     * @return
     */
    <T> T getMapper(Class<T> type);


    /**
     * 提交事务
     */
    void commit() throws SQLException;

    /**
     * 回滚事务
     */
    void rollback() throws SQLException;

}
